import tools from '../tools'
import util from './util'
import allModel from './index'
import log from '../tools/log'

const clz= allModel
console.log(allModel)
export default {
    getClass:(name)=>{
        return clz[name];
    },
    create:(name,record,path)=>{
        // console.log("file: starModel.js:12  name:", name,allModel)
        let obj=clz[name].create(record,path);
        return tools.proxy(obj);
    },
    getTpl:(name, type)=>{
        let obj=clz[name].tpl(type);
        return obj;
    },
    observe(name,record,{get=null,set=null}){
        let obj=clz[name].create(record);
        return tools.proxyObject(obj,{get,set})
    },
    getModelType:(modelType, fixedType='')=>{
        // console.log("file: starModel.js:268  modelType, fixedType:", modelType, fixedType)
        let tmpTypeList = []
        let type = fixedType || modelType
        switch (modelType) {
            // case 'logic':
            // case 'staticLogic':
            // case 'twins':
            // case 'tank':
            //     let type = fixedType || modelType
            //     tmpTypeList = ['List', 'Dictionary', 'Tree', 'Chain', 'TreeChain'].map(item => ({
            //         label: type+item, value: type+item
            //     }))
            //     break;
            // case 'routing':
            //     if (fixedType === 'workCenter') {
            //         tmpTypeList.push({label: 'workCenterDictionary', value: 'workCenterDictionary'})
            //     } else {
            //         tmpTypeList.push({label: 'routing', value: 'routing'})
            //     }
            //     break;
            // case 'process':
            //     tmpTypeList.push({label: 'process', value: 'process'})
            //     break;
            // case 'BI':
            //     tmpTypeList.push({label: 'BI', value: 'BI'})
            //     break;
            // case 'template':
            //     tmpTypeList.push({label: 'template', value: 'template'})
            //     break;
            // case 'statistics':
            //     tmpTypeList.push({label: 'statistics', value: 'statistics'})
            //     break;
            // case 'statTemplate':
            //     tmpTypeList.push({label: 'statisticsTemplate', value: 'statisticsTemplate'})
            //     break;
            // case 'entityRelation':
            //     tmpTypeList.push({label: 'entityRelation', value: 'entityRelation'})
            //     tmpTypeList.push({label: 'entity', value: 'entity'})
            //     break;
            // case 'workCenter':
            //     tmpTypeList.push({label: 'workCenter', value: 'workCenter'})
            //     break;
            // case 'routingRelation':
            //     tmpTypeList.push({label: 'routingRelation', value: 'routingRelation'})
            //     break;
            default:
                tmpTypeList.push({label: type, value: type})
                break;
        }
        return tmpTypeList;
    },
    getHierTpl(){
        return {
            basic:{
                name:'',
                title:'title',
                model:'',
                pointer:{},
                values:{}
            },
            basicTree:{
                id:'',
                parentId:'',
                name:'',
                title:'',
                model:'',
                pointer:{},
                values:{}
            },
            twinsDictionary:{
                basic:[
                    {
                        name:'',
                        title:'title',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
                equipment:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ]
            },
            twinsQueue:{
                basic:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
                equipment:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ]
            },
            twinsTree:{
                basic:[
                    {
                        id:'',
                        parentId:'',
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
                equipment:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ]
            },
            twinsSingleton:{
                basic:{
                    name:'',
                    title:'',
                    model:'',
                    pointer:{},
                    values:{}
                },
                equipment:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ]
            },
            logicDictionary:{
                basic:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            logicQueue:{
                basic:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            logicTree:{
                basic:[
                    {
                        id:'',
                        parentId:'',
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            logicSingleton:{
                basic:{
                    name:'',
                    title:'',
                    model:'',
                    pointer:{},
                    values:{}
                },
            },
            templateDictionary:{
                basic:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            templateQueue:{
                basic:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            templateTree:{
                basic:[
                    {
                        id:'',
                        parentId:'',
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            templateSingleton:{
                basic:{
                    name:'',
                    title:'',
                    model:'',
                    pointer:{},
                    values:{}
                },
            },
        }
    },
    getModelList(locale='en-US'){
        return [
            {label:{"en-US":'entity',"zh-CN":'实体'}[locale],value:'entity'},
            // {label:{"en-US":'twins',"zh-CN":'孪生'}[locale],value:'twins'},
            // {label:{"en-US":'logic',"zh-CN":'逻辑'}[locale],value:'logic'},
            // {label:{"en-US":'template',"zh-CN":'模板'}[locale],value:'template'},
            {label:{"en-US":'statistics',"zh-CN":'统计'}[locale],value:'statistics'},
        ]
    },
    util
}
